All Questions
35 questions
0votes
0answers
39views
How to use set of Python codes that worked for 2 files & loop the codes over multiple file in the same directory on python
I have a set of Python codes that I used to perform a task involving 2 files named code0001_1234_A2023_12.csv & BB_B2024_code0001.csv. Now I would like to perform the same task for all other files ...
0votes
1answer
526views
kdb/Q How to iterate on a function x number of times?
I'm new to kdb/Q, what is the equivalent of iteration, where I need to run a function 10 times? In Python, it would be something like creating some kind of iterator, using a while loop to run the ...
0votes
1answer
63views
Getting error when using while loop to filter duplicates out from a list
I'm trying to open a txt file and get all the words in it, assign it to a list, and filter the list of duplicates. The code in the snippet is what I thought would work, but I'm getting a traceback ...
0votes
2answers
66views
Does this question need a for or while loop or?
A University is testing a new fertilizer. They are interested in how long the fertilizer may be kept before its effectiveness is lost. They have done some calculations that indicate the fertilizer ...
0votes
1answer
81views
Slowing Down Each Iteration of Loop Dom Manipulation
I have having some trouble with slowing down the loop of a for and while loop in javascript. const insertion_sort = function (array) { for (i = 1; i < array.length; i++) { let key_item = ...
2votes
1answer
580views
Iterative solution for achieving convergence
I am trying to calculate n in equation: f = n^2 in iterative way so that f was close to 3 with precision 3 decimal places from bottom. For illustration I am writing here a code which does succesfully ...
0votes
1answer
1kviews
Python: Combine for loop in while loop and iterate rows in a data
I would like to iterate rows of data and print the final row after reaching a condition. My code looks like this D_sum = 4.39e-05 count = 0 while D_sum < 1: for row in df.iterrows(): ...
0votes
2answers
86views
Creating a loop using non-unique ID-numbers in R instead of using rownumbers for the iteration
Really struggled to come up with a proper title but hopefully, this will explain what my problem is: Let's say I have a dataset (or vector) where one column is a numerical Frame_ID column but they are ...
2votes
5answers
4kviews
How to iterate to 100 using a for or while loop and show the sum of each iteration with javascript?
Just doing a small homework. I need to iterate to 100, but also console.log the result of each previous example. Example of the series: (1)+(1+2)+(1+2+3)+…+(1+2+3+…+n)<=100 Iteracion1=1 Iteracion2= ...
0votes
1answer
194views
How to use while loop to check difference between calculation output , convergence calculation
I am writing a code that carry outs the calculation: def elastic_buckling_pressure(corroded_wall_thickness, external_radius_mm, lambda_value,...
0votes
0answers
200views
Passing a variable to iteration variable after break statement
How can I make the iteration variable i take the value of the variable lc after breaking out of the loop? Thank you. Code below: a = [155, 157, 83, 121, 112, 137, 129, 159] b = [145, 148, 66, 117, 101,...
0votes
2answers
15kviews
creating a python lottery program [closed]
import random def randomNum(): for iteration, num in enumerate(range(4)): first = random.randint(1,10) second = random.randint(1,10) third = random.randint(1,10) ...
0votes
1answer
146views
Date in a loop - display the first / skip the rest [closed]
A chat has a message date from an SQL database. The timestamp is formatted with php date: $dateabove = date("d.m.Y : H:i",$row['message_time']); The date is in a loop (while):- Today has ...
0votes
6answers
500views
Using iterations to find smallest k in python
I'm new to programming and I'm trying to work on my iterations. An example of what I'm trying to do is: Enter a positive integer: 100 19 is the smallest n such that 1+3+5+7+...+n >= 100 So from the ...
0votes
1answer
2kviews
Using "Next Page" in while loop
I am retrieving data from an API endpoint which only allows me to retrieve a maximum of 100 data points at a time. There is a "next page" field within the response which I could use to ...